<?php


if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

$action=$_POST['action'];

if($action=='verify'){
    $phone=$_POST['phone'];
    $uid  =$_POST['uid'];
    $name=$_POST['name'];
    $query = C::t('#annual#common_phone')->fetch_phone($phone,$uid);
    if($query){
      echo 0;
    }else{
	  C::t('#annual#common_phone')->insert(array('uid'=>$uid,'name'=>$name,'phone'=>$phone));	
      echo 1;
    }
 }elseif ($action=="talk") {
     $uid  =$_POST['uid'];
     $name= $_POST['name']; 
     $new=$_POST['news'];
     $data=array(
       'uid' =>$_POST['uid'],
       'name'=>$_POST['name'],
       'new' =>$_POST['news'],
       'talk_date'=>date('Y-m-d H:i:s'),
        );
    $re=C::t('#annual#common_news')->insert($data);
    echo $re; 
 }elseif ($action=='newlist') {
     $id=$_POST['nid'];
    $num=C::t('#annual#common_phone')->fetch_count();
    $data=C::t('#annual#common_news')->fetch_all($id);
    $date=array(
       'news'=>$data,
       'num' =>$num['num'],
        );
    echo  json_encode($date);
 }elseif ($action=='word') {
     $file = "source/plugin/annual/word.txt"; 
     $badword = file_get_contents($file); //该文本中为敏感词汇,共有将近4000个 
     $hei = explode("/",$badword); 
     $blacklist="/".implode("|",$hei)."/i";  
     $str=$_POST['word'];   
  if(preg_match($blacklist, $str, $matches)){ 
      echo 1; 
    } else { 
      echo 0; 
   } 
 }








?>